<template>
  <mescroll-uni
    :height="height"
    @init="mescrollInit"
    @down="downCallback"
    @up="upCallback"
    :down="downOption"
    :up="upOption"
    :top="top"
  >
    <slot></slot>
  </mescroll-uni>
</template>

<script>
// 引入mescroll-mixins.js
import MescrollMixin from "./mixin";
export default {
  name: "ScrollUni",
  mixins: [MescrollMixin], // 使用mixin
  props: {
    height: String,
    top: String,
    upUse: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
      // 下拉刷新的配置(可选, 绝大部分情况无需配置)
      downOption: {
        // use: false,
      },
      upOption: {
        use: this.upUse,
      },
    };
  },
  methods: {
    resetUpScroll() {
      this.mescroll.resetUpScroll();
    },
    /*mescroll组件初始化的回调,可获取到mescroll对象 (此处可删,mixins已默认)*/
    mescrollInit(mescroll) {
      this.mescroll = mescroll;
    },
    endBySize(dataSize, totalPage, systime = null) {
      this.mescroll.endBySize(dataSize, totalPage, systime);
    },
    endByPage(dataSize, totalPage, systime = null) {
      this.mescroll.endByPage(dataSize, totalPage, systime);
    },
    /*上拉加载的回调*/
    upCallback(mescroll) {
      this.$emit("upCallback", mescroll);
    },
    downCallback() {
      this.mescroll.resetUpScroll();
    },
  },
};
</script>
